-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): MCP server instrumentation without breaking Miniflare #16817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…improved test isolation
…racing and monitoring
…r MCP server instrumentation
…ibute names to match OTEL draft semantic convention
…r improved instrumentation
…or stdio and SSE transports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, all good from my eyes in overall direction!
Thanks @AbhiPrasad! Will keep working on this and close the other PR using |
yeah as long as it exists when we wrap it I think we are fine. |
…o assign context through request cycle (transport to handlers)
@AbhiPrasad just finished suggested changes + added some new stuff:
|
## DESCRIBE YOUR PR Closes #14106 Adds developer docs for our MCP Server instrumentation. Route for the documentation `sdk/expected-features/mcp-instrumentation` that includes: ```bash .mcp-instrumentation ├── index.mdx # brief description on current features and limitations ├── errors.mdx # draft errors doc └── tracing.mdx # Tracing and span conventions ``` Followed this file structure as a start to (in the future) have this structure for all the other features, having something like this below, where we have : ``` .[Feature 1] ├── index.mdx ├── logs.mdx ├── errors.mdx . . . .[Feature 2] ├── index.mdx ├── errors.mdx ├── tracing.mdx . . . ``` The structure idea is from @abhi, who helped me settle this <3. **NOTE:** Error docs are going to change, addressing feedback from [sentry-javascript/pull/16817](getsentry/sentry-javascript#16817) ## IS YOUR CHANGE URGENT? ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [x] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) --------- Co-authored-by: Alex Krawiec <[email protected]>
Closes #16826, #16654, #16666 #16978
Different approach from #16807 .
Using
Proxy
was causing issues in cloudflare #16182.Now using
fill
we shouldn't have those problems asfill
doesn't create a new wrapper object with a different identity, so now:fill
just replaces the method on the existing objecttransport.start()
runs and accesses private fields, this is still the original transport objectWeakMap
recognizes it as the same object that owns the private fieldsWhat's inside
mcpServerInstance.tool()
,mcpServerInstance.resource()
, etc.)Tracing
It follows OTEL semantic conventions for MCP and adds more attributes we thought are useful.
It also handles PII based on user setting of
sendDefaultPii
.Tracing flow
id: 2
)mcp.server
spanrequestIdToSpanMap[2] = { span, method: "tools/call", startTime }
requestId: 2
completeSpanWithToolResults(2, result)
enriches and completes spanError handling
errorCapture.ts
sendDefaultPii
settingshandlers.ts
isError: true
)transport.ts